local s15__mingshi = fk.CreateSkill({
  name = "s15__mingshi",
  tags = { Skill.Compulsory },
})

Fk:loadTranslationTable {
  ["s15__mingshi"] = "名士",
  [":s15__mingshi"] = "锁定技,已方其他角色对你造成伤害时,你可以弃置一张牌防止之;敌方角色对你造成伤害时,若其手牌数不小于你,伤害-1。",

  ["#s15__mingshi-discard"] = "你可以弃置一张牌防止此伤害",
}

s15__mingshi:addEffect(fk.DamageInflicted, {
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(s15__mingshi.name) and data.from
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if data.from:isFriend(player) then
      if #room:askToDiscard(player, {
            min_num = 1,
            max_num = 1,
            include_equip = false,
            skill_name = s15__mingshi.name,
            cancelable = true,
            pattern = ".",
            prompt = "#s15__mingshi-discard",
          }) == 1 then
        data:preventDamage()
      end
    elseif not data.from:isFriend(player) and data.from:getHandcardNum() >= player:getHandcardNum() then
      data:changeDamage(-1)
    end
  end,
})

return s15__mingshi
